<?php 
    //session_start();
    //ob_start();
    require_once('../../../Connections/ocmanmanager.php');
    require_once('../../../Connections/checkuser.php'); 
?>

<?php
$nameissueid = "-1";
if (isset($_GET['id'])) {
  $nameissueid = $_GET['id'];
}
   //this is the id from issue form. (issuetable).
   $id_issue = $nameissueid;
    
    
    // entry code (add notes)- - -  create error handller.
    if(isset($_POST['save'])){   
    mysql_select_db($database_ocmanmanager, $ocmanmanager);// selecting database.
    $notes = $_POST['notes']; 
    $notetitle= $_POST['notestitle'];
    $issueid = $id_issue;
    $dateadded = date("Y-d-m");
    $addedby = "1";
    $important = "0";
    $deleted = "0";
    
    // run sqlquery of inserting data from the tables (notes).
    
    $query_add_notes = "INSERT INTO issuenotes(notetitle,notes,issueid,dateadded,addedby,important,deleted) VALUE ('$notetitle','$notes','$issueid','$dateadded','$addedby','$important','$deleted')";
    $mysql_result = mysql_query($query_add_notes); 
    header("Location:issue.php?id='$id_issue'");
        /*echo '<script>';        
        echo 'alert("data has been added")';
        echo '</script>'; 
        // java script for pop up menu.*/
    }
?>
<!DOCTYPE html> 
<html> 
	<head> 
	<title>Ozcrete Mobile</title> 
  <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1" />
        	<link rel="stylesheet" href="css/jquery.mobile.css" />
        	<link rel="stylesheet" href="css/jquery.mobile.splitview.css" />
            <link rel="stylesheet"  href="css/jquery.mobile.grids.collapsible.css" />
          <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
          <script type="text/javascript" src="js/jquery.mobile.splitview.js"></script>
          <script type="text/javascript" src="js/jquery.mobile.js"></script>
          <script type="text/javascript" src="js/iscroll-wrapper.js"></script>
          <script type="text/javascript" src="js/iscroll.js"></script>
          <!--script type="text/javascript" src="scrollability.js"></script-->
</head>

<body>
    <div data-role="page" id="add_notes">
        <div data-role="header" data-backbtn="false">
          <h1>Adding notes</h1>
        </div><!-- this is the header -->
        <br/> <br/> <br/>
        <form action="#" method="post">
        <div data-role="fieldcontain" style="width:500px;">
            <label for="notetitle" style="text-align-last: right;"> Note title:
            <input type="text" name="notestitle" id="notestitle" value=""/></label>
        </div>
        <div data-role="fielcontain" style="width:500px;">
            <label for="note">Notes
            <textarea name="notes" id="notes"></textarea>
            </label>
        </div>
        <div class="ui-body ui-body-b">
              <fieldset class="ui-grid-a">
                  <div class="ui-block-a"><button type="submit" name="cancel" data-theme="d">Cancel</button></div>
                  <div class="ui-block-b"><button type="submit" name="save" data-theme="a">Submit</button></div>
                </fieldset>
              </div>
        </form>
    </div>
</body>
</html>